#include "mymainwindow.h"

#include<QDir>
#include <QApplication>
#include<QAbstractItemModel>
#include<QAbstractItemView>
#include<QItemSelectionModel>

#include<QSplitter>
#include<QDirModel>
#include<QFileSystemModel>

#include<QTreeView>
#include<QTableView>
#include<QListView>

#include<QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
//    MyMainWindow w;
//    w.show();

    QFileSystemModel model;
    model.setRootPath(QDir::currentPath());

    qDebug() << "Current working directory:" << QDir::currentPath();


    QTreeView tree;//树形视图
    QListView list;//列表视图
    QTableView table;//表视图

    //设置数据模型
    tree.setModel(&model);
    list.setModel(&model);
    table.setModel(&model);

    tree.setSelectionMode(QAbstractItemView::MultiSelection);
    list.setSelectionModel(tree.selectionModel());
    table.setSelectionModel(tree.selectionModel());

    QObject::connect(&tree,&QTreeView::doubleClicked,&list,&QListView::setRootIndex);
    QObject::connect(&tree,&QTreeView::doubleClicked,&table,&QTableView::setRootIndex);
    QSplitter *qsp=new QSplitter;
    qsp->addWidget(&tree);
    qsp->addWidget(&list);
    qsp->addWidget(&table);
    qsp->show();
    qsp->setWindowTitle("模型--测试");

    return a.exec();
}
